<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            border-collapse: collapse;
            border: 1px solid #333;
            width: 1000px;

        }
        table tr,th,td{
            border: 1px solid #333;
            text-align: center;
        }
        table th{
            width: 20%;
        }
    </style>
</head>
<body>
    <div class="shengao">
        <span>身高：</span>
        <input type="text" >
    </div>
    <div class="tizhong">
        <span>体重：</span>
        <input type="text" >
    </div>
    <button>计算</button>
    <table>
        <thead>
            <tr>
                <th>编号</th>
                <th>日期</th>
                <th>身高</th>
                <th>体重</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody class="te" id="te">
            <!-- <td></td>
            <td></td>
            <td></td>
            <td></td> -->
        </tbody>
       
    </table>
</body>
<script>
    let shengao = document.querySelector('.shengao input')
    let tizhong = document.querySelector('.tizhong input')
    let te = document.querySelector('#te')
    let jisuan = document.querySelector('button')
    let count = 0
    jisuan.onclick = function(){
        let now = new Date()
        let date = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}  ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
        count+=1
        // console.log(date)
        let rowArray = [count,date,shengao.value,tizhong.value,`<a href='javascript:;'>删除</a>`]

        let row = document.createElement('tr')
        for(item of rowArray){
            let td = document.createElement('td')
            td.innerHTML = item
            row.append(td)
           
            // console.log(row)   
        }
        te.append(row)
       
        shengao.value = ''
        tizhong.value = ''

        






        //删除
        let shanchu = document.querySelectorAll('#te td a')
        for(let i =0;i<shanchu.length;i++){
            shanchu[i].onclick = function(){
                this.parentElement.parentElement.remove()
                
            }
        }

    }
    


</script>
</html>
